package com.class06;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(
//       过滤器名称
        filterName = "LifeCycleFilter",
//        过滤器拦截的路径
        urlPatterns = "/servletB")
public class LifeCycleFilter implements Filter {

    //    alt + insert   选中构造器   enter
    public LifeCycleFilter() {
        System.out.println("LifeCycleFilter类过滤器被创建了");
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("LifeCycleFilter过滤器初始化");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
                         FilterChain filterChain) throws IOException, ServletException {
        System.out.println("LifeCycleFilter放行之前");
        filterChain.doFilter(servletRequest, servletResponse);
//        alt + shift + 上下键  移动当前行代码
        System.out.println("LifeCycleFilter放行之后");
    }

    @Override
    public void destroy() {
        System.out.println("LifeCycleFilter过滤器销毁了");
    }
}
